#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>
#include <QPalette>
#include <QSlider>
#include <QTime>
#include <QTimer>
#include <QListWidget>
#include <QProcess>
#include <QFileDialog>
#include <QDebug>
#include <QLabel>
#include <QTextCodec>
#include <QUdpSocket>
#include <QString>
#include <QPainterPath>
#include <qpainter.h>


#include <ctime>



#define DEFAULT_PORT 6666
#define MUL_CASTADDR "242.2.2.2"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void parts_init();
    void QSlider_init();
    void QListWidget_init();
    void scanSong();
private slots:
    void pause_clicked();
    //void exit_clicked();
    void prev_clicked();
    void next_clicked();
    void favorite_clicked();
//    void listcircle_clicked();
    void menu_clicked();
//    void back_message_slot();
//    void getPosTime_timeout();
//    void musicSlide_slot(int value);
//    void volumeSlide_slot(int value);
//    void volume_clicked();
//    void volume_timeout();
//    void addfile_clicked();
//    void cd_timeout();
//    void songList_itemClicked();



    /* 加入组播 */
    void joinGroup();





    /* 接收到消息 */
    void receiveMessages();


    /* 连接状态改变槽函数 */
    void socketStateChange(QAbstractSocket::SocketState);

private:
    Ui::MainWindow *ui;
    QProcess *process;
    QPalette Pic;

    /* Udp通信套接字 */
    QUdpSocket *udpSocket;

     int fd[2];

    QFileInfoList songFilelist;


    QTimer *timer_cd;
    QTimer *timer_getPosTime;
    QTimer *timer_vol;

    int cur_time,length_time,value;
    QSlider *music_Slider,*volume_Slider;//进度条

    QPushButton *prev_button, *pause_button, *next_button, *exit_button, *volume_button, *addfile_button,
                *favorite_button, *listcircle_button, *menu_button;

    QListWidget *songList;//播放列表

    QLabel *label_cd;
    QLabel *lable_SongTitle; //歌曲名称

    QLabel *lable_Songcurrent_time;//显示 当前时间
    QLabel *lable_SongTotal_time;//显示 总时间

#include <QMetaType>                            //自定义参数类型的头文件----***
struct msg_listentry_st{
    uint8_t chnid;  /* channel num  */
    uint16_t len;
    uint8_t desc[1];/*  describe channel  information*/
};

struct  msg_list_st
{
    uint8_t chnid;  /* channel num  */
    struct msg_listentry_st entry[1];

};

struct  msg_channel_st
{
   uint8_t  chinid;
  uint8_t data[1];
};

typedef uint8_t chnid_t;
};
#endif // MAINWINDOW_H
